﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Facebook;
using System.Dynamic;

namespace TestFB.Code
{
    public class FacebookManager
    {
        private FacebookClient _cliente;

        public static string ApplicationID { get { return "355279404566156"; } }
        public static string ApplicationSecret { get { return "5ada7707b586ca54aae182e34c2b0e27"; } }


        public FacebookManager()
        {
            
        }

        public void GetToken()
        {
            _cliente = new FacebookClient();
            dynamic result = _cliente.Get("oauth/access_token", new
            {
                client_id = ApplicationID,
                client_secret = ApplicationSecret,
                grant_type = "client_credentials"
            });

            _cliente.AccessToken = result.access_token;
        }

        public void ObtenerAmigos(string userID)
        {
            GetToken();
            //var query = string.Format("SELECT uid, name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = {0})", ApplicationID);

            //dynamic parameters = new ExpandoObject();
            //parameters.q = query;
            //dynamic results = _cliente.Get("/fql", parameters);
            dynamic results = _cliente.Get("/andres.lorusso/permissions");
        }
    }
}